package com.lxl.settings.dao;

import com.lxl.commons.utils.DbUtil;
import com.lxl.settings.entity.User;


import javax.servlet.jsp.jstl.sql.Result;
import java.sql.SQLException;

/**
 * @author 北上寻海
 */
public class UserDaoImpl implements UserDao {
    @Override
    public Result selectUserByCondition(String username, String password) throws SQLException {
        String sql = "select id,user_name,password from tbl_user where user_name= ? and password = ?";
        return   DbUtil.select(sql,username,password);
    }

    @Override
    public int insertUserByCondition(User user) throws SQLException {
        String sql = "insert into tbl_user values('"+user.getId()+"','"+user.getUsername()+"','"+user.getPassword()+"')";
        return DbUtil.insert(sql);
    }

    @Override
    public Result selectUserById(String id) throws SQLException {
        String sql = "select id,user_name,password from tbl_user where id = '"+id+"'";
        return DbUtil.select(sql);
    }
}
